<#include "../include/public.ftl"/>

<@head_add_edit title="用户-新增"/>

    <@body_empty>
        <@form_padding title="新增用户">
            <@input label="用户名" name="username" placeholder="请输入用户名" require="false"/>
            <@input label="密码" name="password" placeholder="请输入密码" require="false"/>
            <button class="layui-btn" lay-submit lay-filter="*" style="display: none">立即提交</button>
        </@form_padding>
    </@body_empty>
<@footer>
<script>
    layui.use(['element','form', 'layer'], function(){
        var form = layui.form;
        var $ = layui.jquery;

        form.on('submit(*)', function(data){
            $.ajax({
                type: "POST",
                url: "/admin/user/add",
                contentType: "application/json",
                data: JSON.stringify(data.field),
                success: function (res) {
                    if (res.code === 0) {
                        parent.layui.table.reload('myTable');
                        layer.msg("添加成功！");
                        parent.layer.closeAll();
                    } else {
                        layer.alert(res.msg);
                    }
                }
            });
            return false;
        });
    });
</script>
</@footer>